package com.imay.live.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextPaint;
import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.view.View;
import android.widget.TextView;

import com.imay.base.activity.BaseActivity;
import com.imay.live.model.HelpModel;
import com.imay.base.util.SpannableStringUtils;
import com.imay.live.R;


/**
 * created by nick
 * 我的-设置-帮助和反馈-帮助详情
 */
public class HelpDetailActivity extends BaseActivity {

    private static final String TAG_HELP_MODEL = "tag_help_model";
    private static final String TAG_HELP_TITLE = "tag_help_title";
    private TextView tv_title;
    private TextView tv_content;
    private TextView tv_contact_customer_service;

    public static void start(Context context, HelpModel.HelpItemModel model,String title) {
        Intent starter = new Intent(context, HelpDetailActivity.class);
        starter.putExtra(TAG_HELP_MODEL,model);
        starter.putExtra(TAG_HELP_TITLE,title);
        context.startActivity(starter);
    }
    @Override
    protected int getLayoutId() {
        return R.layout.activity_help_detail;
    }

    @Override
    protected void initView(Bundle savedInstanceState) {
        bindViews();
        HelpModel.HelpItemModel model = (HelpModel.HelpItemModel) getIntent().getSerializableExtra(TAG_HELP_MODEL);
        String title = getIntent().getStringExtra(TAG_HELP_TITLE);
        setTitle(title);
        tv_title.setText(model.getName());
        tv_content.setText(model.getContent());
        tv_contact_customer_service.setText(SpannableStringUtils.getBuilder(getString(R.string.help_hint)).append(getString(R.string.help_contact_customer_service)).setClickSpan(new ClickableSpan() {
            @Override
            public void onClick(View widget) {
                AboutIMayActivity.start(HelpDetailActivity.this);
            }

            @Override
            public void updateDrawState(TextPaint ds) {
                super.updateDrawState(ds);
                ds.setColor(getResources().getColor(R.color.text_url));

            }
        }).create());
        tv_contact_customer_service.setMovementMethod(LinkMovementMethod.getInstance());

    }

    private void bindViews() {
        tv_title = (TextView) findViewById(R.id.tv_title);
        tv_content = (TextView) findViewById(R.id.tv_content);
        tv_contact_customer_service = (TextView) findViewById(R.id.tv_contact_customer_service);

    }


}
